package com.exam.controller;

import com.exam.dto.ActionResult;
import com.exam.po.JudgeQuestion;
import com.exam.service.JudgeQuestionService;
import org.omg.PortableInterceptor.ACTIVE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName JudgeQuestionController
 * @Description TODO
 * @action luoliang
 * @Data 2021/1/12 11:39
 * @Version 1.0
 */
@RestController
@RequestMapping("/api")
public class JudgeQuestionController {

    @Autowired
    private JudgeQuestionService judgeQuestionService;
    /**
     * 添加
     * @param record
     * @return
     */
    @RequestMapping(value = "/judgeQuestion",method = RequestMethod.POST)
    public ActionResult Addjudge(@RequestBody JudgeQuestion record){
        //System.out.println(record);

        int insert = judgeQuestionService.Insert(record);
        //System.out.println(insert);
        //System.out.println("22222");
            if (insert>0){
                //System.out.println("1111111");
                ActionResult success = new ActionResult(200, "success", insert);
                return success;
            }else {
                ActionResult error = new ActionResult(203, "error", null);
                return error;
            }
    }
    @RequestMapping(value = "/judgeQuestionId",method = RequestMethod.GET)
    public ActionResult FindJudge(Integer questionid){
        JudgeQuestion judgeQuestion = judgeQuestionService.SelectByPrimaryKey(questionid);
        if (judgeQuestion != null){
            ActionResult success = new ActionResult(200, "success", judgeQuestion);
            return success;
        }else {
            ActionResult error = new ActionResult(203, "error", null);
            return  error;
        }
    }
}
